package com.oracle.sbdb.dao;

import org.apache.ibatis.session.SqlSession;

import com.oracle.sbdb.model.Component;

public class ComponentDao {
	public Component selectbyId(int componentId){
		SqlSession session = SessionFactory.getSession();
		Component res = session.selectOne("com.oracle.mybatis.ComponentMapper.selectComponent", componentId);
		session.commit();
		session.close();
		return res;
	}
	
	public int selectCount() {
		SqlSession session = SessionFactory.getSession();
		int res = session.selectOne("com.oracle.mybatis.ComponentMapper.selectComponentCount");
		session.commit();
		session.close();
		return res;
	}
	
	public void insert(Component Component) {
		SqlSession session = SessionFactory.getSession();
		session.selectOne("com.oracle.mybatis.ComponentMapper.insertComponent", Component);
		session.commit();
		session.close();
	}
	
	public void update(Component Component) {
		SqlSession session = SessionFactory.getSession();
		session.selectOne("com.oracle.mybatis.ComponentMapper.updateComponent", Component);
		session.commit();
		session.close();
	}
	
	public void delete(int componentId) {
		SqlSession session = SessionFactory.getSession();
		session.selectOne("com.oracle.mybatis.ComponentMapper.deleteComponent", componentId);
		session.commit();
		session.close();
	}
}
